package com.spider.admin.service.async;

import com.spider.admin.exception.SpiderException;
import com.spider.admin.service.client.PublishClientTenantsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AsyncService {

    @Autowired
    private PublishClientTenantsService publishClientTenantsService;
    @Async
    public void asyncRefashPermsCache() {
        // 异步执行的任务
        try {
            publishClientTenantsService.putToCacheForPerms();
        } catch (SpiderException e) {
            log.info("刷新服务权限缓存失败："+e.getMessage());
        }
    }

    @Async
    public void asyncRefashServiceInfoCache(){
        try {
            publishClientTenantsService.putToCacheForServiceInfo();
        } catch (SpiderException e) {
            log.info("刷新服务信息缓存失败："+e.getMessage());
        }
    }

    @Async
    public void asyncRefashLogsSettingsCache(){
        try {
            publishClientTenantsService.putToCacheForLogSettingInfo();
        } catch (SpiderException e) {
            log.info("刷新日志采集配置缓存失败："+e.getMessage());
        }
    }
}
